<?php

namespace Cms\Article;

class Reply extends \Model {
    
    use \UserModel;

    static public $table = 'cms_article_reply';
    protected $_fillable = array(
        'article_id' => 'int',
        'uid' => 'int',
        'nickname' => 'str',
        'content' => 'str',
        'avatar' => 'str'
    );
    
    public function countByActicle($article_id) {
        $where = array(
            'article_id' => $article_id,
        );
        return Db()->count(static::$table)->where($where)->result();
    }
    
    public function getListByArticle($article_id) {
        $where = array(
            'article_id' => $article_id,
        );
        return Db()->getAll(static::$table)->where($where)->result();
    }
    
    public function removeByArticle($id, $article_id) {
        $where = array(
            'id' => $id,
            'article_id' => $article_id,
        );
        return Db()->delete(static::$table, $where);
    }

}
